<?php
/**
 * 添加产品产品信息
 * 2013年4月19日10:09:06
 * cgp
 */
//print_r($_POST);
use \pft\Prod\Product;
include 'common/autoload.php';
include 'common/Prod_Common.php';
include 'common/prodField_dt.php';
$ptype = strtoupper($_REQUEST['type']);
$uploadUrl = 'call/uploadThumbImage.php';
$saveBtn = '<button class="ui-button ui-button-lblue" id="saveProduct" data-wrap="ticketBox" type="button">保存，下一步</button>';
$apply_did = $_SESSION['dtype']==6? $_SESSION['sid'] : $_SESSION['memberID'];
if($_SESSION['dtype']==6) {
    if(\pft\Member\MemberAccount::GetMemType($_SESSION['sid'])!=0) {
        exit('您的上级不是供应商身份，无法发布产品。');
    }
}
elseif($_SESSION['dtype']!=0 && $_SESSION['dtype']!=9) {
    exit('您不是供应商身份，无法发布产品。');
}
$obj = new Product($GLOBALS['le']);
$page_title = '产品发布';
$topicList = array();//产品主题
$delaytime = array();//延迟
if(isset($_GET['sid']) && abs($_GET['sid']>0)) {
    $page_title = '产品编辑';
    $isedit = empty($_GET['step'])? true : false ;
    $product_id = abs($_GET['sid']);

    $jdata = $obj->GetProductById($product_id);
    $apply_did = $jdata['apply_did'];
    $ptype = $jdata['p_type'];
    $topicList = explode(',', $jdata['topic']);
    $delaytime = explode('|', $jdata['delaytime']);
    //echo $ptype;
    if($jdata['attribute']) {
        //echo $jdata['attribute'];
        $package_data = $obj->PackageDataFormat($jdata['attribute']);
        $input_pack = "<input type='hidden' value='{$jdata['attribute']}' name='package_attr'/>";
    }
    $saveBtn = '<button class="ui-button ui-button-lblue" id="saveProduct" type="button">保存</button>';
}
$imgUrl = !empty($jdata['imgpath']) ? $jdata['imgpath'] :'images/defaultThum.jpg';
$package_str_tpl = '<li><p>产品名:{}</p></li>';
if($ptype == 'F' && !empty($_POST['package_data'])) {
    $attribute = urldecode($_POST['package_data']);
    $package_data = $obj->PackageDataFormat($attribute);
    $input_pack = "<input type='hidden' value='{$attribute}' name='package_attr'/>";
}
$page_title = "产品发布 - ";
include 'common/header.html';
include 'common/left.html';
include TPLPATH.'_product_body.html';
include('common/footer.html')?>